package com.hkemmm.DBdriver;

import com.hkemmm.bean.UserInfoBean;
import com.hkemmm.control.LoginControl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class testDriver {
    public static void main(String[] args) {
//        UserInfoBean userInfoBean = new UserInfoBean();
//        System.out.println("通过new创建的java bean对象：" + userInfoBean);

        //test1();

        test2();
    }

    public static void test1(){
        ApplicationContext context = new ClassPathXmlApplicationContext("springconfig.xml");

        Object objuserInfoBean1 = context.getBean("UserInfoBean");
        System.out.println("spring容器获取java bean对象：" + objuserInfoBean1);

        Object objuserInfoBean2 = context.getBean("UserInfoBean");
        System.out.println("spring容器获取java bean对象：" + objuserInfoBean2);


        System.out.println("objuserInfoBean1==objuserInfoBean2:  "+(objuserInfoBean1==objuserInfoBean2));
    }

    public static void test2(){
        ApplicationContext context = new ClassPathXmlApplicationContext("springconfig.xml");
        LoginControl loginControl = (LoginControl) context.getBean("LoginControl");

        loginControl.doLogin();
    }
}
